package com.kiki.singer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kiki.common.annotation.Log;
import com.kiki.common.core.controller.BaseController;
import com.kiki.common.core.domain.AjaxResult;
import com.kiki.common.enums.BusinessType;
import com.kiki.singer.domain.Singer;
import com.kiki.singer.service.ISingerService;
import com.kiki.common.utils.poi.ExcelUtil;
import com.kiki.common.core.page.TableDataInfo;

/**
 * 歌手基础信息Controller
 * 
 * @author 林志毅
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/singer/singer")
public class SingerController extends BaseController
{
    @Autowired
    private ISingerService singerService;

    @GetMapping("/listSingerByKeyWord/{keyword}")
    public List<Singer> listSingerByKeyWord(@PathVariable("keyword") String keyword)
    {
        return singerService.listSingerByKeyWord(keyword);
    }

    /**
     * 查询歌手基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('singer:singer:list')")
    @GetMapping("/list")
    public List<Singer> list(Singer singer)
    {
        return singerService.selectSingerList(singer);
    }

    /**
     * 导出歌手基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('singer:singer:export')")
    @Log(title = "歌手基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Singer singer)
    {
        List<Singer> list = singerService.selectSingerList(singer);
        ExcelUtil<Singer> util = new ExcelUtil<Singer>(Singer.class);
        util.exportExcel(response, list, "歌手基础信息数据");
    }

    /**
     * 获取歌手基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('singer:singer:query')")
    @GetMapping(value = "/{singerId}")
    public AjaxResult getInfo(@PathVariable("singerId") Long singerId)
    {
        return success(singerService.selectSingerBySingerId(singerId));
    }

    /**
     * 新增歌手基础信息
     */
    @PreAuthorize("@ss.hasPermi('singer:singer:add')")
    @Log(title = "歌手基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Singer singer)
    {
        return toAjax(singerService.insertSinger(singer));
    }

    /**
     * 修改歌手基础信息
     */
    @PreAuthorize("@ss.hasPermi('singer:singer:edit')")
    @Log(title = "歌手基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Singer singer)
    {
        return toAjax(singerService.updateSinger(singer));
    }

    /**
     * 删除歌手基础信息
     */
    @PreAuthorize("@ss.hasPermi('singer:singer:remove')")
    @Log(title = "歌手基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{singerIds}")
    public AjaxResult remove(@PathVariable Long[] singerIds)
    {
        return toAjax(singerService.deleteSingerBySingerIds(singerIds));
    }
}
